import java.util.Arrays;
import java.util.Scanner;

/**
 * @author 雷明浩
 * @date 2025/8/22 16:00
 */
public class Test1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        char[] cc = in.nextLine().toCharArray();
        Arrays.sort(cc);
        int mid = cc.length / 2;
        long ret = 0;
        for (int i = 0; i < cc.length; i++) {
            if (i < mid) {
                ret += Math.min(cc[mid]-cc[i], cc[i]-'a'+'z'-cc[mid]+1);
            } else {
                ret += Math.min(cc[i]-cc[mid], 'z'-cc[i]+cc[mid]-'a'+1);
            }
        }
        System.out.println(ret);
    }
}